
<div id="menu_tree" class='gridlist finder-list catlist'>
    <{foreach from=$list item=item name="item"}>
    <div depath="<{$item.menu_depth}>" class="clear_cat row <{if $env.foreach.item.iteration%2>0}>even<{/if}>" menu_id="<{$item.menu_id}>" parent_id="<{$item.parent_id}>">
        <div class='row-line' style="padding:0">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td width="5%" style="vertical-align:top"><{$item.menu_id}></td>
                    <td width="15%" style="vertical-align:top">
                        <div style="padding-left:<{($item.menu_depth)*15}>px;text-align:left">
                            <{if $item.has_children=='true'}>
                            <span class="handle-menu" style='width:12px; height:12px;line-height:12px;overflow:hidden;display:inline-block;*margin-right:5px;cursor:pointer'>
                                <{img app='desktop' src="bundle/handle-hide.gif" alt=$___weixin="收起子菜单"|t:'weixin'  title=$___weixin="收起子菜单"|t:'weixin'  class="handle-hide" app='desktop'}>
                                <{img app='desktop' src="bundle/handle-show.gif" alt=$___weixin="收起子菜单"|t:'weixin'  title=$___weixin="展开子菜单"|t:'weixin'  class="handle-show" app='desktop'}>
                            </span>
                            <{/if}>
                            <a href='index.php?app=weixin&ctl=admin_menu&act=edit&menu_id=<{$item.menu_id}>&bind_id=<{$item.bind_id}>&menu_theme=<{$item.menu_theme}>' target="dialog::{title:'<{t}>编辑<{/t}>',width:.7,height:.8}">
                                <{$item.menu_name|t:'weixin'}>
                            </a>
                        </div>
                    </td>
                    <td width="35%" style="vertical-align:top">
                        <{$item.content}>
                    </td>
                    <td width="15%" style="vertical-align:top">
                        <input class="_x_ipt" type="number" size="5"  name="ordernum[<{$item.menu_id}>]" value="<{$item.ordernum|default:0}>" vtype="unsigned" style="display:none" />
                        <b><{$item.ordernum|default:0}></b>
                    </td>
                    <td width="30%" style="vertical-align:top">
                        <div class="clearfix">
                            <div class="span-auto">
                                <{if $item.menu_depth==1}>
                                <{assign var="menu_id" value=$item.menu_id}>
                                <span class="opt lnk" onClick="new Dialog('index.php?app=weixin&ctl=admin_menu&act=add&parent_id=<{$item.menu_id}>&bind_id=<{$item.bind_id}>&menu_theme=<{$item.menu_theme}>', {title:'<{t}>添加子菜单<{/t}>',height:0.7,width:0.6})">
                                    <{img src="bundle/addcate.gif" border="0" alt=$___weixin="添加子菜单"|t:'weixin'  app='desktop'}>
                                    <{t}>添加子菜单<{/t}>
                                </span>
                                <{else}>
                                <span class="">
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;
                                </span>
                                <{/if}>
                            </div>
                            <div class="span-auto">
                                <span class="opt lnk" onClick="new Dialog('index.php?app=weixin&ctl=admin_menu&act=edit&menu_id=<{$item.menu_id}>&bind_id=<{$item.bind_id}>&menu_theme=<{$item.menu_theme}>', {title:'<{t}>编辑<{/t}>',height:0.7,width:0.6})">
                                    <{img src="bundle/editcate.gif" border="0" alt=$___weixin="编辑"|t:'weixin'   app='desktop'}>
                                    <{t}>编辑<{/t}>
                                </span>
                            </div>
                            <div class="span-auto">
                                <span class="opt lnk" onclick="deleteRow('index.php?app=weixin&ctl=admin_menu&act=remove&menu_id=<{$item.menu_id}>',event)">
                                    <{img src="bundle/delecate.gif" border="0" alt=$___weixin="删除"|t:'weixin'  app='desktop'}>
                                    <{t}>删除<{/t}>
                                </span>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <{/foreach}>
</div>

<script>
$('menu_tree').addEvent('click',function(e){
    if(!e.target.className.match(/handle-/i))return;
    var handle=$(e.stop().target);
    var eventRow=handle.getParent('.row');
    var visible=handle.hasClass('handle-show')?'':'none';
    if(visible=='none'){
        handle.hide().getNext().show();
    }else{
        handle.hide().getPrevious().show();
    }
    flode(eventRow,visible);
});

function flode(eventRow,visible){
    var menu_id=eventRow.get('menu_id');
    var parent_id=eventRow.get('parent_id');
    eventRow.getAllNext('div[parent_id='+menu_id+']').each(function(row){
    if(visible=='none'){
        row.hide();
        var obj=row.getElements('.handle-menu img');
        if(obj.length>1){
            flode(row,visible);
        }
    }else{
        row.show();
        var obj=row.getElements('.handle-menu img');
        if(obj.length>1){
            var vis=(obj[0].getStyle('display')=='none'?'none':'inline');
            flode(row,vis);
        }
    }
    });
}

</script>